HAL IRDA migration: List of applicable concepts

This section provides information about the HAL IRDA applicable architecture concepts.

Concepts for IRDA

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate init and config functions:

  • HAL_UART_Init(): initialize the handle and link it to an USART instance.

  • HAL_UART_IRDA_SetConfig(): sets the configuration to enable the use of the USART instance.

Removal and conversion of init structure to configuration structure

The init structure IRDA_InitTypeDef has been removed from the handle .

Renaming of the handle structure

No more HAL IRDA handle. The HAL IRDA Driver is now used with the hal_uart_handle_t.

Renaming unitary init structures

The structure IRDA_InitTypeDef is no longer available and is replaced by hal_uart_irda_config_t.

Remove MspInit and MspDeInit callbacks

HAL_IRDA_MspInit() and HAL_IRDA_MspDeInit() are no longer available and have been replaced by a user-defined sequence to initialize and configure the UART.

Unitary configuration APIs

New APIs are available to get and set IRDA features.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro is no longer provided and new functions HAL_UART_SetTxDMA() and HAL_UART_SetRxDMA() are provided to link a UART HAL handle to a DMA HAL handle.

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each IRDA event. These functions are used to register callback functions for different IRDA events.

HAL implementation with LL inline functions

HAL IRDA APIs now rely on LL APIs rather than performing direct register access.

Define statements and enumerations redirected to LL equivalents

HAL IRDA define statements and enumerations are based on LL define statements.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL IRDA driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The IRDA now shares the same state machine as the UART, which is managed by three state machines:

  1. Global state machine

  2. Transmission state machine

  3. Reception state machine

Revised and optimized HAL API status returns

The HAL IRDA functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Redesign the error handling mechanisms within the HAL to improve the detection, reporting, and handling of errors. This rework aims to provide more detailed and consistent error information such as HAL_UART_ERROR_PE and HAL_UART_ERROR_ORE.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL IRDA driver have been removed and replaced by _t.

Replaced multi-line macros with inline functions

For the HAL IRDA driver, large macros have been replaced by inline functions to maintain code consistency, improve readability, and benefit from compiler optimization. Inline functions also offer better support for debugging and strict type management, reducing the risk of errors.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Merge HAL extension files with common ones and remove the EX prefix from APIs.

Only one HAL IRDA header file remains and all macros, define statements, and functions from hal_irda_ex.h have been moved to hal_irda.h.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including IRDA instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL IRDA functions start with HAL_UART_IRDA.